﻿namespace Charades.Web.Helpers
{
	using System;
	using System.Collections.Generic;
	using System.IO;
	using System.Linq;

	public static class WordsHelper
	{
		private static readonly List<string> Words = new List<string>();
		private static readonly Random Random = new Random();

		static WordsHelper()
		{
			var path = AppDomain.CurrentDomain.BaseDirectory + @"App_Data\word_base.txt";
			Words = File.ReadAllLines(path).ToList();

			//File.WriteAllLines(AppDomain.CurrentDomain.BaseDirectory + @"App_Data\word_base2.txt", words);
		}

		public static string[] GetWords()
		{
			var res = new string[3];
			res[0] = Words[Random.Next(0, Words.Count - 1)].ToUpper();
			res[1] = Words[Random.Next(0, Words.Count - 1)].ToUpper();
			res[2] = Words[Random.Next(0, Words.Count - 1)].ToUpper();
			return res;
		}
	}
}